//因为在首页和详情页都有,所以在做成公共模板
// let str = `<div>{{name}}</div>`  //演示
// let obj = { name: '张三' }
// //拼接得到结果
// let html = template.render(str, obj)
// console.log(html);

//获取热门推荐获取书数据
$.get('/posts/recommend', function (response) {
    let str = `
        {{each data}}
        <li>
            <a href="detail.html?id={{$value._id}}">
            <img src="{{$value.thumbnail}}" alt="">
            <span>{{$value.title}}</span>
            </a>
        </li>
        {{/each}}
    `
    let html = template.render(str, { data: response })
    $('.hots ul').html(html)
})